package com.hmall.search.pojo;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.hmall.common.pojo.Item;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Arrays;
import java.util.List;

@Data
@NoArgsConstructor
public class ItemDoc {
    private Long id;//id
    private String name;//SKU名称
    private Long price;//价格(分)
    private Integer sold;//销量
    private String brand;//品牌名称
    private String category;//类目名称
    private Integer commentCount;//评论数
    private String image;//商品图片
    private Integer stock;//库存
    @JsonProperty(value = "isAD")
    private boolean isAD;//是否是广告
    private List<String> suggestion;

    public ItemDoc(Item item){
        this.id = item.getId();
        this.name = item.getName();
        this.price = item.getPrice();
        this.sold = item.getSold();
        this.brand = item.getBrand();
        this.category = item.getCategory();
        this.commentCount = item.getCommentCount();
        this.image = item.getImage();
        this.stock = item.getStock();
        this.isAD = item.getIsAD();
        this.suggestion = Arrays.asList(this.brand,this.category);
    }
}
